package cn.zhibang.sannuo.web.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author AdminController
 * @version 1.0.0
 * @ClassName SwaggerConfig.java
 * @Description TODO
 * @createTime 2021年03月29日 16:12:00
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket Api1(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(hui())
                .enable(true)
                .groupName("账号管理")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zhibang.sannuo.account.api"))
                .build();
    }
    @Bean
    public Docket Api2(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(hui())
                .enable(true)
                .groupName("系统维护")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zhibang.sannuo.maintenance.api"))
                .build();
    }
    @Bean
    public Docket Api3(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(hui())
                .enable(true)
                .groupName("个人中心")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zhibang.sannuo.mycenter.api"))
                .build();
    }
    @Bean
    public Docket Api4(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(hui())
                .enable(true)
                .groupName("药房管理")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zhibang.sannuo.pharmacy.api"))
                .build();
    }
    private ApiInfo hui(){
        Contact contact = new Contact("辉", "", "");
        return new ApiInfo("辉的Api",
                "权限操作",
                "v1.0",
                "",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
    @Bean
    public Docket Api5(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(yan())
                .enable(true)
                .groupName("报表管理")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zhibang.sannuo.repoty.api"))
                .build();
    }
    private ApiInfo yan(){
        Contact contact = new Contact("燕", "", "");
        return new ApiInfo("燕的Api",
                "报表管理",
                "v1.0",
                "",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
    @Bean
    public Docket Api6(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(sheng())
                .enable(true)
                .groupName("用户检测")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zhibang.sannuo.user_detection.api"))
                .build();
    }
    private ApiInfo sheng(){
        Contact contact = new Contact("易胜", "", "");
        return new ApiInfo("易胜的Api",
                "用户检测",
                "v1.0",
                "",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }

}
